package com.jasonzqshen.ifm.mvc.models;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.RoundedRectangle;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartListener;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;

import com.jasonzqshen.ifm.featureModelCore.FeatureModel;
import com.jasonzqshen.ifm.utils.SystemLog;

public class FeatureModelEditPart extends AbstractGraphicalEditPart {

    private RoundedRectangle rectangle;

    private FeatureModel featureModel;
    
    private EditPartListener listener = new EditPartListener()
    {
        @Override
        public void childAdded(EditPart child, int index) {
            // TODO Auto-generated method stub
            
        }

        @Override
        public void partActivated(EditPart editpart) {
            // TODO Auto-generated method stub
            
        }

        @Override
        public void partDeactivated(EditPart editpart) {
            // TODO Auto-generated method stub
            
        }

        @Override
        public void removingChild(EditPart child, int index) {
            // TODO Auto-generated method stub
            
        }

        @Override
        public void selectedStateChanged(EditPart editpart) {
            // TODO Auto-generated method stub
            
        }
        
    };

    public FeatureModelEditPart() {
        rectangle = new RoundedRectangle();
        Display display = Display.getCurrent();
        Color c = display.getSystemColor(0);

        Color color = new Color(c.getDevice(), 183, 238, 251);

        SystemLog.logInfo(String.format("Blue: %d, Red %d, Green %d",
                color.getBlue(), color.getRed(), color.getGreen()));
        rectangle.setBackgroundColor(color);
        rectangle.setSize(2000, 100);

        RoundedRectangle child = new RoundedRectangle();
        child.setLocation(new Point(0, 0));
        child.setSize(10, 10);
        
        FeatureNodeEditPart editPart = new FeatureNodeEditPart(null);
        this.rectangle.add(editPart.createFigure());
    }

    /**
     * Get figure
     */
    @Override
    protected IFigure createFigure() {
        return rectangle;
    }

    /**
     * Get
     */
    @Override
    protected void createEditPolicies() {
        // TODO Auto-generated method stub

    }

    @Override
    public Object getModel() {
        return this.featureModel;
    }
}
